<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt"%>

 <%
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/";
 %>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
		<link rel="stylesheet" type="text/css" href="<%=basePath %>/css/updateVideo.css" />
		<link rel="stylesheet" href="<%=basePath %>css/list.css">
		<link href="<%=basePath %>css/H-ui.min.css" rel="stylesheet" type="text/css" />
		<link href="<%=basePath %>/css/H-ui.min.css" rel="stylesheet" type="text/css" />
		<link href="<%=basePath %>/css/formsCSS.css" rel="stylesheet" type="text/css" />
		<script src="<%=basePath %>/js/jquery.min.js"></script>
		<script src="<%=basePath %>/js/formsJS.js"></script>
		<!-- kindeditor富文本编辑器 -->
		<link href="<%=basePath%>/kindeditor/themes/default/default.css">
		<link href="<%=basePath%>/kindeditor/plugins/code/prettify.css">
		<script src="<%=basePath%>/kindeditor/lang/zh-CN.js"></script>
		<script src="<%=basePath%>/kindeditor/kindeditor-all.js"></script>
		

<script type="text/javascript">

function checkForm(f){

	
	if(f.chapterName.value.replace(/\s/g,'') == ''){
		alert("章节名称不能为空");
		return false;
	}
	
	if(f.orderNum.value.replace(/\s/g,'') == ''){
		alert("章节排序不能为空");
		return false;
	}
	if(f.courseId.value.replace(/\s/g,'') == ''){
		alert("所属课程不能为空");
		return false;
	}
	if(f.chapterStatus.value.replace(/\s/g,'') == ''){
		alert("章节状态不能为空");
		return false;
	}
	if(f.chapterType.value.replace(/\s/g,'') == ''){
		alert("章节类型不能为空");
		return false;
	}
	
	if(f.chapterDesc.value.replace(/\s/g,'') == ''){
		alert("章节详情不能为空");
		return false;
	}
	
 
	return true;
}
	

</script>
</head>
<body>
		<div class="connect_wrap">
    		<h3 style= "text-align: center;">课程章节信息维护</h3>
			<div class="row cl" style="max-width:88%;margin-left:8%;">
			<div class="labelText"></div>
				<form action="<%=basePath%>/courseChapter/courseChapterEdit" method="post" onsubmit="return checkForm(this)"
					enctype="multipart/form-data">
					<div class="col-sm-4"></div>
	    					<div class="col-sm-4">
	    							<div class="boxs">
												<input type="hidden" name="id" value="${courseChapter.id}">
												<input type="text" class="inputBox" placeholder="章节名称" name="chapterName" value="${courseChapter.chapterName}" >
												<input type="text" class="inputBox" placeholder="章节副标题" name="chapterSubtitle" value="${courseChapter.chapterSubtitle}" >
												
												<input type="text" class="inputBox" placeholder="章节价格" name="chapterPrice" value="${courseChapter.chapterPrice}" required="required">
												<input type="text" class="inputBox" placeholder="章节原价" name="chapterOrignalPrice" value="${courseChapter.chapterOrignalPrice}" required="required" >
												<input type="text" class="inputBox" placeholder="课程章节时长" name="chapterDuration" value="${courseChapter.chapterDuration}">
												<input type="number" class="inputBox" placeholder="排序" name="orderNum"  value="${courseChapter.orderNum}">
													
												<select class="selectBox" name="courseId" id="courseId">
								    				<option value="">----所属课程----</option>
									    			<c:forEach items="${courses}" var="c">
									    				<option value="${c.id}" ${c.id == courseChapter.courseId ? 'selected="selected"' : ''}>${c.id}:${c.courseName}</option>
									    			</c:forEach>
					    						</select>
					    						<select id="chapterStatus" name="chapterStatus" class="selectBox"  >
												  	<option value="">章节状态</option>
												  	<option value="1" ${courseChapter.chapterStatus == 1 ? 'selected="seelcted"' : '' }>上线</option>
										  			<option value="2" ${courseChapter.chapterStatus == 2 ? 'selected="seelcted"' : '' }>下线</option>
												</select>
												<input type="file" class="inputBox" placeholder="上传图片" name="imgFile"  
													value="${courseChapter.imgPath}">
												<input type="text" class="inputBox" placeholder="视频路径" name="videoPath" value="${courseChapter.videoPath}" >
												<input type="text" class="inputBox" placeholder="章节编号" name="chapterNumber" value="${courseChapter.chapterNumber}" required="required">
												 <br/><br/>
												<select id="chapterType" name="chapterType" class="selectBox"  >
												  	<option value="">课程章节类型</option>
												  	<option value="1" ${courseChapter.chapterType == 1 ? 'selected="seelcted"' : '' }>免费</option>
										  			<option value="2" ${courseChapter.chapterType == 2 ? 'selected="seelcted"' : '' }>付费</option>
												</select>
  												<br>
 												<textarea  id="chapterDesc" placeholder="章节详情" name="chapterDesc" class="inputBox kindeditor" style="width: 90%;">${courseChapter.chapterDesc}</textarea>
												 
												 
												<input type="submit" value="确定" class="true" />
												<input type="button"  class="false" value="取消" onclick="window.history.go(-1)">
										</div>
								</div>
					</form>
			</div>
	</div>
	
</body>
<script type="text/javascript">
var editor;
KindEditor.ready(function(K) {
	
    editor = K.create('#chapterDesc', {
            uploadJson : '<%=basePath%>kindeditor/upload',       
            fillDescAfterUploadImage: false,
            allowImageRemote:false,
            afterCreate : function() {
                var self = this;
                K.ctrl(document, 13, function() {
                    self.sync();
                });
                K.ctrl(self.edit.doc, 13, function() {
                    self.sync();
                });
            },
            afterBlur:function(){ 
                this.sync(); 
            } 
        });
});  

</script>
	 
</html>